# -*- coding: utf-8 -*-
"""
@date: 2021/8/31 10:58
@file: shape.py
@author: lilong
@desc: 
"""

"""
参考：https://blog.csdn.net/nijiayan123/article/details/85780440
"""

import numpy as np
from keras import backend as K


tf_session = K.get_session()
val = np.array([[1, 2, 3], [3, 4, 5]])
kvar = K.variable(value=val)
print("kvar:", K.shape(kvar))   # 2维
print("int_shape:", K.int_shape(kvar))  # 各维度大小

input = K.placeholder(shape=(2, 4, 5, 6))  # 4维
print("input shape:", K.shape(input))
print("input int_shape:", K.int_shape(input))

print(K.shape(kvar).eval(session=tf_session))
print(K.shape(kvar).eval(session=tf_session))
print(K.shape(val)[0].eval(session=tf_session))
